package com.sunshine.springboot.dto.system;


import com.fasterxml.jackson.annotation.JsonInclude;
import com.sunshine.springboot.constant.ResultCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

/**
 * 响应类
 *
 * @author WeiHong
 * @date 2018/8/14
 */
@Getter
@Setter
@ToString
public class Result {
    /**
     * 状态响应码
     */
    private int code;

    /**
     * 响应结果 成功/失败
     */
    private boolean success;

    /**
     * 响应信息
     */
    private String message;

    /**
     * 响应数据
     */
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private Object data;

    public Result() {
    }

    public Result(ResultCode resultCode, boolean success, String message) {
        this.code = resultCode.getCode();
        this.success = success;
        this.message = message;
    }

    public Result setData(Object data){
        this.data = data;
        return this;
    }

}
